import http from './http.js'
import qs from 'qs' //axios自带的格式化组件

export function list(parentId = 0) {
  return http({
    method: 'get',
    url: `/manage/category/list?parentId=${parentId}`,
  })
}

export function add(data) {
  return http({
    method: 'post',
    url: `/manage/category/add`,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: qs.stringify({ ...data }),
  })
}

export function update(data) {
  return http({
    method: 'post',
    url: `/manage/category/update`,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: qs.stringify({ ...data }),
  })
}
